import { reqcatelist } from "../../http/api"

let state = {
    arr:[]
}
let getters = {
    arr({arr}){
        return arr
    }
}
let mutations = {
    changeArr(state,arr){
        state.arr=arr
    }
}
let actions = {
    reqArr(context){
        return new Promise((resolve,reject)=>{
            reqcatelist({istree:true}).then(res=>{
                if(res.data.code===200){
                    let arr = res.data.list?res.data.list:[]
                    context.commit("changeArr",arr)
                    resolve()
                }
            })
        })
    }
}

export default  {
    state,
    getters,
    mutations,
    actions,
    namespaced:true
}